package com.hdu.hdu;



import com.hdu.hdu.chain.InterceptorChain;
import com.hdu.hdu.chainFactory.InterceptorChainFactory;
import com.hdu.hdu.context.StudentInfoCheckContext;
import com.hdu.hdu.domain.Student;
import com.hdu.hdu.interceptor.EmailCheckInterceptor;
import com.hdu.hdu.interceptor.NameCheckInterceptor;
import com.hdu.hdu.interceptor.PhoneNumberCheckInterceptor;
import com.hdu.hdu.interceptorFIlter.ConfigInterceptorFilter;

import java.util.Arrays;


public class Main {
    public static void main(String[] args) {


        Student student = new Student();
        student.setEmail("123445@qq.com");
        student.setPhoneNumber("18580705432");
        student.setUsername("qyh");

        StudentInfoCheckContext context = new StudentInfoCheckContext(student);


        InterceptorChain<StudentInfoCheckContext> interceptorChain = InterceptorChainFactory.createStudentCheckInterceptorChain(
                new ConfigInterceptorFilter(
                        Arrays.asList(
                                NameCheckInterceptor.class.getName(),
                                EmailCheckInterceptor.class.getName(),
                                PhoneNumberCheckInterceptor.class.getName()
                        )
                ),
                new NameCheckInterceptor(),
                new EmailCheckInterceptor(),
                new PhoneNumberCheckInterceptor()
        );

        interceptorChain.process(context);
    }
}